from Crypto.PublicKey import RSA

if __name__ == "__main__":
    key = RSA.generate(8192)
    with open("private.pem", "wb") as file:
        private_key = key.export_key()
        file.write(private_key)

    with open("public.pem", "wb") as file_out:
        public_key = key.publickey().export_key()
        file_out.write(public_key)
